package node.dao;

import hibernate.mappings.MsNode;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import util.DBConnection;

public class NodeDao {

	public List getNodeList(int parent) {
		List list = new ArrayList();
		String sql = "select * from ms_node where parent=" + parent;
		DBConnection dbc = new DBConnection();
		ResultSet rs = dbc.query(sql);
		try {
			while (rs.next()) {
				MsNode node = new MsNode();
				//node.setDocid(rs.getInt("docid"));
				node.setDpub(rs.getInt("dpub"));
				node.setHref(rs.getString("href"));
				node.setId(rs.getInt("id"));
				node.setNpub(rs.getInt("npub"));
				node.setNtype(rs.getInt("ntype"));
				node.setParent(parent);
				//node.setSiteid(rs.getInt("siteid"));
				node.setTablename(rs.getString("tablename"));
				node.setTitle(rs.getString("title"));
				list.add(node);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			dbc.close();
		}

		return list;
	}

}
